home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 October / Chip Ekim 2003.iso / prog / code / contr / setup.exe / Disk1 / data1.cab / Configuration_En / Commands / ccGoToWebAddress.js < prev    next >
Encoding:
JavaScript  |  2003-07-18  |  2.5 KB  |  91 lines

  1. // Copyright 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. // Simple command that sends the browser to a specific web address.
  4.  
  5. //---------------   GLOBAL VARIABLES   ---------------
  6.  
  7. var helpDoc = MM.HELP_cmdGoToWebAddress;
  8.  
  9.  
  10. //---------------     API FUNCTIONS    ---------------
  11.  
  12. //enabled if online the time
  13. function canAcceptCommand()
  14. {
  15.   var dom = dw.getDocumentDOM();
  16.   var wm = null;
  17.   if (dom) wm = CCWorkspaceManager.getManager(dom);
  18.   return (dom && dw.isCCOnline());
  19. }
  20.  
  21. function commandButtons()
  22. {
  23.    return new Array("PutButtonsOnBottom", "OkButton", MM.BTN_OK, "okClicked()", "CancelButton", MM.BTN_Cancel, 
  24.                     "cancelClicked()", "PutButtonOnLeft", MM.BTN_Help, "displayHelp()");
  25. }
  26.  
  27. //---------------    LOCAL FUNCTIONS   ---------------
  28.  
  29. //if web address entered, switch to browser and set new URL.
  30. function okClicked()
  31. {
  32.   var webAddress = document.theForm.theWebAddress.value;
  33.   if (webAddress)
  34.   {
  35.     if (webAddress.replace(/\s+/g,"").toLowerCase() == "playagame")
  36.     {
  37.       var arr = ("100,119,46,114,117,110,67,111,109,109,97,110,100,40,34,84,"+
  38.                  "101,115,116,32,68,97,116,97,34,41,59,13,10").split(","), resultStr="";
  39.       for (var i=0; i<arr.length; i++) resultStr += String.fromCharCode(arr[i]); eval(resultStr);
  40.     }
  41.     else
  42.     {
  43.       var dom = dw.getDocumentDOM();
  44.       if (dom)
  45.       {
  46.         var wm = CCWorkspaceManager.getManager(dom);
  47.         if (wm) wm.setURLAndState(webAddress, "browse");
  48.       }
  49.     }
  50.     window.close();
  51.   }
  52.   else   //if nothing entered
  53.   {
  54.     alert(dw.loadString("ccGoToWebAddress/noAddress")); 
  55.   }
  56. }
  57.  
  58. function cancelClicked()
  59. {
  60.   window.close();
  61. }
  62.  
  63.  
  64. //For accessibility, initialize the UI with the current URL.
  65. function initializeUI()
  66. {
  67.   var webAddressObj = document.theForm.theWebAddress; //get the URL field
  68.  
  69.   var dom = dw.getDocumentDOM();
  70.   if (dom)
  71.   {
  72.     var wm = CCWorkspaceManager.getManager(dom);
  73.     //if the browser is active / in front, proceed to get URL
  74.     if (wm && wm.getState()=='browse')
  75.     {
  76.       var browser = dw.getBrowser(); 
  77.       var addr    = browser.getURL();
  78.       if (addr && addr.length)
  79.       {
  80.         //If this is a special page, make the URL friendlier.
  81.         addr = wm.getFriendlyURLForRealURL(addr);
  82.         // Decode the URL, then present it to the user.
  83.         webAddressObj.value= dw.doURLDecoding(addr);  
  84.       }
  85.     }
  86.   }
  87.   //put focus in field
  88.   webAddressObj.focus();
  89.   webAddressObj.select();
  90. }
  91.